<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>{$web_name} - 基本参数</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__HOME__/static/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__HOME__/static/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">网站设置</div>
                <div class="layui-card-body" pad15>
                    <form id="systemForm" action="" method="post">
                        <div class="layui-form" wid100 lay-filter="">
                            <div class="layui-form-item">
                                <label class="layui-form-label">{$web_name['info']}</label>
                                <div class="layui-input-block">
                                    <input type="text" name="web_name" class="layui-input" value="{$web_name['value']}">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">{$web_url['info']}</label>
                                <div class="layui-input-block">
                                    <input type="text" name="web_url" value="{$web_url['value']}" lay-verify="url" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">{$icp_num['info']}</label>
                                <div class="layui-input-block">
                                    <input type="text" name="icp_num" value="{$icp_num['value']}" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">{$system_sms['info']}</label>
                                <div class="layui-input-block">
                                    <select name="system_sms"  id="system_sms" >
                                        <option value="1" >邮件验证码</option>
                                        <option value="2" >阿里云短信</option>
                                        <option value="3" >腾讯云短信</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">{$system_state['info']}</label>
                                <div class="layui-input-block">
                                    <select name="system_state"  id="system_state" >
                                        <option value="1" >正常</option>
                                        <option value="2" >维护模式（首页提示维护,生成的短网址不受限）</option>
                                        <option value="3" >整站维护模式（首页以及生成的短网址都提示维护）</option>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-form-item layui-form-text">
                                <label class="layui-form-label">{$system_state_text['info']}</label>
                                <div class="layui-input-block">
                                    <textarea name="system_state_text" class="layui-textarea" > {$system_state_text['value']} </textarea>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="set_website" >确认保存</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="__HOME__/static/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '__HOME__/static/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use([ 'index', 'form','element'],function() {
        var $ = layui.$
            ,form = layui.form;
        $("#system_state").find("option[value='"+ {$system_state['value']}+"']").attr("selected",true);
        $("#system_sms").find("option[value='"+ {$system_sms['value']}+"']").attr("selected",true);
        layui.form.render();
        form.on('submit(set_website)', function(data){
            //获取请求数据
            //使用ajax发送请求
            $.ajax({
                type: 'POST',
                url: '{fun:ctr("systemSet")}',
                dataType:'json',
                data:data.field,
                xhrFields: {
                    withCredentials: true
                },
                headers: {'X-Requested-With': 'XMLHttpRequest'},
                cache:false,
                crossDomain: true,
                success:function(data){
                    if(data.code == 200){
                        layer.msg(data.msg, {icon: 1});
                        window.setTimeout(function () {
                            window.location.reload();
                        }, 500);
                    }else if(data.code == -7){
                        layer.msg(data.msg, {icon: 2});
                        window.setTimeout(function () {
                            top.location = '{fun:ctr("../Login")}';
                        }, 1000);
                    }else{
                        layer.msg(data.msg, {icon: 2});
                    }
                },
                error: function(data){
                    console.log(data);
                    layer.msg('数据异常，操作失败！');
                },
            });
            return false;  //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>
</body>
</html>